package com.bluemor.reddotface.adapter;

import java.util.List;

import com.bluemor.reddotface.R;



import android.content.Context;
import android.graphics.Bitmap;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;

public class HomeListviewAdapter extends BaseAdapter {
	private Context context;
	private List<Bitmap> images;
	
	public HomeListviewAdapter(Context context,List<Bitmap> images){
		this.context = context;
		this.images = images;
	}
	
	@Override
	public int getCount() {
		return images.size();
	}

	@Override
	public Object getItem(int position) {
		return images.get(position);
	}

	@Override
	public long getItemId(int position) {
		return position;
	}

	@Override
	public View getView(int position, View convertView, ViewGroup parent) {
		ViewHolder viewHolder;
		if (convertView == null) {
			LayoutInflater inflater = LayoutInflater.from(context);
			convertView = inflater.inflate(R.layout.home_listviewitem,null);
			viewHolder = new ViewHolder();
			viewHolder.imageView = (ImageView) convertView.findViewById(R.id.homelistview_item_imageview);
			convertView.setTag(viewHolder);
		}else {
			viewHolder = (ViewHolder) convertView.getTag();
		}
		viewHolder.imageView.setImageBitmap(images.get(position));
		return convertView;
	}

	static class ViewHolder{
		ImageView imageView;
	}
}
